package com.mobile.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 请求拦截器
 *
 * @author Administrator
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Value("${static.file.path}")
    private String staticFilePath;
    @Value("${static.file.path.course.word}")
    private String wordPath;
    @Value("${static.file.path.course.ppt}")
    private String pptPath;
    @Value("${static.file.path.course.video}")
    private String videoPath;
    @Value("${static.file.path.course.image}")
    private String imagePath;

    /**
     * 本地文件路径映射
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(
                        wordPath + "**",
                        pptPath + "**",
                        videoPath + "**",
                        imagePath + "**")
                .addResourceLocations(
                        "file:" + staticFilePath + wordPath,
                        "file:" + staticFilePath + pptPath,
                        "file:" + staticFilePath + videoPath,
                        "file:" + staticFilePath + imagePath);
    }



}
